package companyCategory;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class ComCategoryMapper extends Mapper<LongWritable, Text, Text, Text> {

    private Text city = new Text();
    private Text companyType = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        if (line.contains("city")) {
            return;//跳过dyh
        }
        String[] fields = line.split(",");
        if (fields.length >= 8) {
            city.set(fields[7]);
            companyType.set(fields[2]);

            context.write(city, companyType);
        }
    }
}
